
public class Liczba {
	public int n, podstawa;
	public String s = "";
	
	public Liczba(int _n, int _podstawa)
	{
		n = _n;
		podstawa =_podstawa;
	}
	
	public void zamiana()
	{
		if(podstawa == 10)
			System.out.print(n);
		else if(podstawa == 16 || podstawa == 17)
		{
			String s = "";
			int  c;
			
			do{
				c = n % podstawa;
				
				if(c>=10)
				{
					switch(c)
					{
					 
					  case 10 :
						  s = 'a'+s;
						  break;
					  case 11 :
						  s = 'b'+s;
						  break;
					  case 12 :
						  s = 'c'+s;
						  break;
					  case 13 :
						  s = 'd'+s;
						  break;
					  case 14 :
						  s = 'e'+s;
						  break;
					  case 15 :
						  s = 'f'+s;
						  break;
					  case 16 :
						  s = 'g' + s;
						  break;
					}
					
				}
				else
				   s=(char)(c+48) + s;
				
				n = n/podstawa;
				
			}while(n != 0);
			
			System.out.print(s);
			
		}
		else
		{
			
			int  c;
			
			do{
				c = n % podstawa;
				s=(char)(c+48) + s;
				n = n/podstawa;
				
			}while(n != 0);
			
			System.out.print(s);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Liczba obj = new Liczba(500, 10);
		obj.zamiana();

	}

}
